import selenium
import selenium.webdriver  # 模拟浏览器
import re
import pymysql

arr = []  # id数组

try:
    conn = pymysql.connect(  # 连接数据库
        host="127.0.0.1",
        user="root", password="",
        database="pdd",
        charset="utf8"
        )

    cursor = conn.cursor()  # 数据的游标

    cursor.execute('select goods_id from pdd_goods_list')
    # cursor.execute("insert into pdd_detail values('1037201811','2018-09-13/03fab2ade51542225d661b9cb45efb9d.jpeg')")
    # conn.commit() #插入语句生效
    data = cursor.fetchall()  
    for (i,) in data:
        arr.append(i)  
    conn.close()
except:
    print("密码错误")

# print(arr)  

def getnumberbyname(searchname):
    url = "http://mobile.yangkeduo.com/goods.html?goods_id="+searchname+""
    driver = selenium.webdriver.Firefox()
    driver.get(url)
    pagesource = driver.page_source  
    # print(pagesource)
    restr = r'<ul class="islider-outer">.*?src=\"(.*?)\".*?src=\"(.*?)\".*?src=\"(.*?)\".*?</ul>'
    regex = re.compile(restr, re.IGNORECASE)
    mylist = regex.findall(pagesource)
    driver.close() 
    return mylist


for item in arr:     
    print(getnumberbyname(item))

# print(getnumberbyname(arr[0]))